{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% load static %}
{% load ietf_filters %}
{% load static %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}IPR disclosures{% endblock %}
{% block content %}
    {% origin %}
    {% include "ipr/search_form.html" %}
    <h2 class="mt-5">
        {% block search_header %}Patent owner/applicant search result{% endblock %}
    </h2>
    {% block search_result %}
        {% if not iprs %}
            <p class="alert alert-success my-3">
                {% block search_failed %}No IPR disclosures have been submitted by "{{ q }}".{% endblock %}
            </p>
        {% else %}
            <p class="alert alert-info my-3">
                Total number of IPR disclosures found: <b>{{ iprs|length }}</b>.
            </p>
            <table class="table table-sm table-striped tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="date">Date</th>
                        <th scope="col" data-sort="id">ID</th>
                        <th scope="col" data-sort="statement">Statement</th>
                    </tr>
                </thead>
                {% block iprlist %}
                    {% for ipr in iprs %}
                        {% if user|has_role:"Secretariat" %}
                            {% ifchanged %}
                                <tbody>
                                    <tr class="table-warning">
                                        <th scope="col" colspan="3">{{ ipr.state.name }}</th>
                                    </tr>
                                </tbody>
                            {% endifchanged %}
                        {% endif %}
                        <tbody>
                            <tr class="table-info">
                                <th scope="col" colspan="3">
                                    {% block intro_prefix %}IPR that was submitted by "{{ q }}" and{% endblock %}
                                    {% block related %}
                                        {% with ipr.iprdocrel_set.all as iprdocrels %}
                                            {% if not iprdocrels %}
                                                is not related to a specific IETF contribution.
                                            {% else %}
                                                is related to
                                                {% for item in iprdocrels %}
                                                    {% if forloop.last and forloop.counter > 1 %}and{% endif %}
                                                    {{ item.formatted_name|urlize_ietf_docs }}{% if item.document.title %} ("{{ item.document.title }}"){% endif %}{% if not forloop.last and forloop.counter > 1 %},{% endif %}
                                                {% endfor %}
                                            {% endif %}
                                        {% endwith %}
                                    {% endblock %}
                                    {% block intro_suffix %}{% endblock %}
                                </th>
                            </tr>
                        </tbody>
                        <tbody>
                            <tr>
                                <td>{{ ipr.time|date:"Y-m-d" }}</td>
                                <td>{{ ipr.id }}</td>
                                <td>
                                    <a href="{% url "ietf.ipr.views.show" id=ipr.id %}">{{ ipr.title }}</a>
                                </td>
                            </tr>
                            {% for item in ipr.updates.all %}
                                {% if item != ipr %}
                                    <tr>
                                        <td>{{ item.target.time|date:"Y-m-d" }}</td>
                                        <td>{{ item.target.id }}</td>
                                        <td>
                                            IPR disclosure #{{ ipr.id }}:
                                            <a href="{% url "ietf.ipr.views.show" id=ipr.id %}">{{ ipr.title }}</a>
                                            <br>
                                            Updates:
                                            <a href="{% url "ietf.ipr.views.show" id=item.target.id %}">{{ item.target.title }}</a>
                                        </td>
                                    </tr>
                                {% endif %}
                            {% endfor %}
                        </tbody>
                    {% endfor %}
                {% endblock %}
            </table>
        {% endif %}
    {% endblock %}
    <p class="buttonlist">
        <a class="btn btn-secondary float-end"
           href="{% url "ietf.ipr.views.showlist" %}">Back</a>
    </p>
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
    <script src="{% static 'ietf/js/ipr-search.js' %}"></script>
{% endblock %}